package zz.demo.springCloud.config;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by zhangzheng on 2017-7-21.
 */
public class CustomOaInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        HttpSession session = httpServletRequest.getSession() ;
        String URL = httpServletRequest.getRequestURI() ;
        System.out.println("--------------preHandle start-------------");
        System.out.println(URL);
        System.out.println("---------------preHandle end--------------");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
        HttpSession session = httpServletRequest.getSession() ;
        String URL = httpServletRequest.getRequestURI() ;
        System.out.println("--------------postHandle start-------------");
        System.out.println(URL);
        ExecutorService executorService = Executors.newCachedThreadPool();
        System.out.println("---------------postHandle end--------------");
    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
        HttpSession session = httpServletRequest.getSession() ;
        String URL = httpServletRequest.getRequestURI() ;
        System.out.println("--------------afterCompletion start-------------");
        System.out.println(URL);
        System.out.println("---------------afterCompletion end--------------");
    }
}
